//
// Created by k on 25-6-24.
//

#ifndef CHASSIS_H
#define CHASSIS_H

#include <string>
// #include "serial_driver.h"

typedef struct
{
    float aim_x_vel;
    float aim_y_vel;
    float aim_z_vel;
    uint32_t light;

    uint32_t state;
    uint32_t power;
    float voltage;
    float current;
    float vel_x;
    float vel_y;
    float vel_z;
    float odom_x;
    float odom_y;
    float odom_z;
    uint32_t cmd;
    uint32_t io;
    uint32_t err;
} ChassisData;

typedef enum
{
    SYS_INIT = 0x00,
    SYS_NORMAL,
    SYS_REMOTE,
    SYS_ESTOP,
    SYS_CALIB,
    SYS_TEST,
    SYS_CHARGING,

    SYS_ERR = 0x10,
    SYS_ERR_ID,
    SYS_ERR_COM,
    SYS_ERR_ENC,
    SYS_ERR_COLLISION,
    SYS_ERR_LOW_VOLTAGE,
    SYS_ERR_OVER_VOLTAGE,
    SYS_ERR_OVER_CURRENT,
    SYS_ERR_OVER_TEMP,
    SYS_STATE_LEN,
} SystemState;

bool chassisInit(std::string &dev);

bool getVersion(char *data);
bool setText(const char *text);
bool updateChassisInfo(ChassisData *data);
bool setSysCmd(uint32_t cmd);
bool setIo(uint32_t io);

#endif
